package ecom;

import java.io.Serializable;
import java.security.Principal;
import java.util.*;

import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;

import ecom.api.*;

@ManagedBean
@SessionScoped
public class TestGetUser implements Serializable {

	String user;
	
	public String getUser() {
		
		String st;
		try{
		javax.naming.Context ic = new javax.naming.InitialContext();
		ITestGetIdentifier hell = (ITestGetIdentifier)ic.lookup("ecom.TestGetIdentifier@Remote");
		st =  hell.getUserName();
		user = new String(st); 
		}catch(Exception e){
			String rez = new String(e.getMessage());			
			return rez;
		}
		if(st==null)
		{
			String rez = new String("null");
			return rez;
		}
		else {
			//user = new String(rez);
			return st;
		}
	}

	public void setUser(String user) {
		
		this.user = user;
	}

	public String GetTheUser() throws Exception {

		
		return user;
	
	}

}
